#!/bin/bash
cd ~/app-root/data/github-sh/pkg/
wget -t1 -l1 -np -nd --accept=html http://keepass.info/translations.html 
grep -o "http://downloads.sourceforge.net/keepass/KeePass-[0-9\.]\{3,8\}-Chinese_Simplified.zip" translations.html | sed -e 1d -e 's#http:#https:#' >url.txt
sed -i "/source=/c\source=\($(cat url.txt)\)" ~/app-root/data/temp/pkg/keepass-zh-cn/PKGBUILD
sed -i "/source =/c\source = $(cat url.txt)" ~/app-root/data/temp/pkg/keepass-zh-cn/.SRCINFO
grep -o "[0-9\.]\{3,8\}" url.txt >ver.txt
sed -i "/pkgver=/c\pkgver=$(cat ver.txt)" ~/app-root/data/temp/pkg/keepass-zh-cn/PKGBUILD
sed -i "/pkgver /c\pkgver = $(cat ver.txt)" ~/app-root/data/temp/pkg/keepass-zh-cn/.SRCINFO
cd ~/app-root/data/temp/pkg/
diff -q keepass-zh-cn/ tmp/keepass-zh-cn/ | sed -e 's#Files ##' -e 's#and.*differ##' >diff.txt
zip pkg.zip -r $(cat diff.txt)
rm -rf keepass-zh-cn/ ~/app-root/data/github-sh/pkg/*.html ~/app-root/data/github-sh/pkg/*.txt
